package com.machine.bootstatemachine.app;

import com.machine.bootstatemachine.domain.Order;
import com.machine.bootstatemachine.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @Author daijinwu01
 * @Date 2021/12/27
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping(value = "/create")
    public void create() {
        Order order = new Order();
        order.setOrderId(1L);
        order.setPrice(new BigDecimal("100.011"));
        orderService.create(order);
    }

    @PostMapping(value = "/pay")
    public void pay() {
        Order order = new Order();
        order.setId(1L);
        order.setOrderId(1L);
        orderService.payOrder(order);
    }

    @PostMapping(value = "/done")
    public void done() {
        Order order = new Order();
        order.setId(1L);
        order.setOrderId(1L);
        orderService.orderDone(order);
    }

}
